package com.zziq.mianshi.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zziq.mianshi.model.dto.user.UserQueryRequest;
import com.zziq.mianshi.model.entity.User;
import com.zziq.mianshi.model.vo.LoginUserVO;
import com.zziq.mianshi.model.vo.UserVO;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;

/**
 * 用户服务
 */
public interface UserService extends IService<User> {

    /** @Title:
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:10:53
     * @param userAccount   用户账户
     * @param userPassword  用户密码
     * @param checkPassword 校验密码
     * @return 新用户 id
     * @Description: 用户注册
     */

    long userRegister(String userAccount, String userPassword, String checkPassword);


    /** @Title: userLogin
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:11:26
     * @Params: [userAccount 用户账户, userPassword 用户密码, request]
     * @Return: LoginUserVO 脱敏后的用户信息
     * @Description: 用户登录
     */
    LoginUserVO userLogin(String userAccount, String userPassword, HttpServletRequest request);

    /** @Title: userLoginByMpOpen
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:12:04
     * @Params: [wxOAuth2UserInfo 从微信获取的用户信息, request]
     * @Return: LoginUserVO 脱敏后的用户信息
     * @Description: 用户登录（微信开放平台）
     */
    LoginUserVO userLoginByMpOpen(WxOAuth2UserInfo wxOAuth2UserInfo, HttpServletRequest request);

    /** @Title: getLoginUser
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:12:22
     * @Params: [request]
     * @Return: User
     * @Description: 获取当前登录用户
     */
    User getLoginUser(HttpServletRequest request);

    /** @Title: getLoginUserPermitNull
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:12:28
     * @Params: [request] 
     * @Return: User
     * @Description: 获取当前登录用户（允许未登录）
     */
    User getLoginUserPermitNull(HttpServletRequest request);

    /** @Title: isAdmin
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:12:33
     * @Params: [request] 
     * @Return: boolean
     * @Description: 是否为管理员
     */
    boolean isAdmin(HttpServletRequest request);

    /** @Title: isAdmin
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:12:38
     * @Params: [user] 
     * @Return: boolean
     * @Description: 是否为管理员
     */
    boolean isAdmin(User user);

    /** @Title: userLogout
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:12:42
     * @Params: [request] 
     * @Return: boolean
     * @Description: 用户注销
     */
    boolean userLogout(HttpServletRequest request);

    /** @Title: getLoginUserVO
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:12:59
     * @Params: [user]
     * @Return: LoginUserVO
     * @Description: 获取脱敏的已登录用户信息
     */
    LoginUserVO getLoginUserVO(User user);

    /** @Title: getUserVO
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:13:05
     * @Params: [user]
     * @Return: UserVO
     * @Description: 获取脱敏的用户信息
     */
    UserVO getUserVO(User user);

    /** @Title: getUserVO
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:13:11
     * @Params: [userList]
     * @Return: List<UserVO>
     * @Description: 获取脱敏的用户信息
     */
    List<UserVO> getUserVO(List<User> userList);

    /** @Title: getQueryWrapper
     * @Author: Mr·zziq
     * @Date: 2024-12-04 19:13:17
     * @Params: [userQueryRequest]
     * @Return: QueryWrapper<User>
     * @Description: 获取查询条件
     */
    QueryWrapper<User> getQueryWrapper(UserQueryRequest userQueryRequest);

    boolean addUserSignIn(long userId);

    /** @Title: getUserSignInRecord
     * @Author: Mr·zziq
     * @Date: 2024-12-07 17:36:58
     * @Params: [userId]
     * @Return: Map<LocalDate,Integer>
     *
     * @Description: 获取用户签到记录
     */
    List<Integer> getUserSignInRecord(long userId,Integer year);
}
